import org.apache.spark.sql.SparkSession
import org.apache.spark.sql.functions._

val spark = SparkSession.builder
val salesDF = spark.read.format("csv")
  .option("header", "true")
  .option("inferSchema", "true")
  .load("sales_data.csv")

val groupedDF = salesDF.groupBy($"Product")
  .agg(
    sum("Quantity").as("TotalQuantity"),
    sum($"Quantity" * $"Price").as("TotalRevenue")
  )

groupedDF.show()

